import React , { Component } from 'react';
import { withRouter,NavLink,Switch,Redirect,Route} from 'react-router-dom';
import axios from 'axios';
import {observer,inject} from 'mobx-react';
// 导入需要的模块
@withRouter
@inject('obs','newobs')
@observer
class View extends Component {

    newobs = this.props.newobs;
    async getApi(url,cfg,headers){
        let	data = await axios.get(url,{params:cfg},
        {
            headers: headers
        })
        return data;
    }
    getHome(id){
        const cfg = {
            page_number:id,
            page_size:'10'
        };
        this.getApi('/home/mediareports',cfg,{}).then((res)=>{
            this.setState({
                newData:res.data.data
            })
        })
    }
    storeAjax(id){
        const { getApi } = this.newobs;
        const cfg = {
            page_number:id,
            page_size:'10'
        };
        getApi('/home/mediareports',cfg,{}).then((res)=>{
            console.log(res.data.data)
            // if(res.data.code==1){
            //     let data = res.data.msg;
            //     this.setState({
            //         data:data,
            //         cls:true
            //     })
            // }
        })
    }
    componentDidMount(){
        this.getHome(1);
        this.storeAjax(1);
    }
    render(){
        console.log(this.props.first)
        const { name,personCfg } = this.newobs;
        return (
            <React.Fragment>
                <div className="mian">这是event面</div>
                <NavLink to="/">首页</NavLink><br/>
                <NavLink to="/input">表单</NavLink><br/>
                <NavLink to="/event">事件</NavLink><br/>
                <NavLink to="/storedemo">storedemo</NavLink><br/>
                <NavLink to="/observable">observable</NavLink><br/>
                <NavLink to="/newobs">newobs</NavLink><br/>
                <dl>
                    <dt>{name}</dt>
                    <dd>{personCfg.name}</dd>
                    <dd>{personCfg.age}</dd>
                    <dd>{personCfg.sex}</dd>
                </dl>
            </React.Fragment>
        )
    }
}
export default View;
